<?php $this->assign("title", "Reporte Afluencia"); ?>
<?php
	$this->start("css");
?>
	<style type="text/css">
		form div.submit {
			text-align: center;
		}
		body > * {
			min-width: initial;
		}
	</style>
<?php
	echo $this->Html->css('jquery-ui/jquery-ui-1.10.3.custom.min.css');
	$this->end();

	$this->start('script');
		$this->Html->script("jquery-ui-1.10.3.custom.min", array("inline" => false));
?>

<script type="text/javascript">
	$(function () {
		$.datepicker.regional['es'] = {
			closeText: 'Cerrar',
			prevText: '&#x3C;Ant',
			nextText: 'Sig&#x3E;',
			currentText: 'Hoy',
			monthNames: ['enero','febrero','marzo','abril','mayo','junio',
			'julio','agosto','septiembre','octubre','noviembre','diciembre'],
			monthNamesShort: ['ene','feb','mar','abr','may','jun',
			'jul','ago','sep','oct','nov','dic'],
			dayNames: ['domingo','lunes','martes','miércoles','jueves','viernes','sábado'],
			dayNamesShort: ['dom','lun','mar','mié','juv','vie','sáb'],
			dayNamesMin: ['D','L','M','W','J','V','S'],
			weekHeader: 'Sm',
			dateFormat: 'mm/dd/yy',
			firstDay: 1,
			isRTL: false,
			showMonthAfterYear: false,
			yearSuffix: ''
		};
		$.datepicker.setDefaults($.datepicker.regional['es']);
		$("#ReporteFechaI").datepicker({
				changeMonth: true,
				changeYear: true,
				onClose: function( selectedDate ) {
				$( "#ReporteFechaF" ).datepicker( "option", "minDate", selectedDate );
			}
		});
		$("#ReporteFechaF").datepicker({
				changeMonth: true,
				changeYear: true,
				onClose: function( selectedDate ) {
					$( "#ReporteFechaI" ).datepicker( "option", "maxDate", selectedDate );
				}
		});
	});

        if (!window.dataTableProcessing) {
            window.dataTableProcessing = {};
        }
        dataTableProcessing.afluenciaTable = {
            "oTableTools": {
                "aButtons": [
                    {
                        "sExtends": "collection",
                        "sButtonText": "Guardar como",
                        "aButtons": [
                            {
                                "sExtends": "xls",
                                "sButtonText": "Excel"
                            },
                            {
                                "sExtends": "pdf",
                                "sButtonText": "PDF"
                            }
                        ]
                    }
                ],
                "sSwfPath": "../files/swf/copy_csv_xls_pdf.swf"
            }
        };
</script>

<?php
	$this->end();

	echo $this->Form->create('Reporte');
?>
<table>
	<caption>Reporte Afluencia</caption>
	<tr>
		<td>Fecha Inicial:</td>
		<td>Fecha Final:</td>
	</tr>
	<tr>
		<td>
			<?php echo $this->Form->input('fecha_i', array(
				'label' => false,
		   		));
		   	?>
		</td>
		<td>
			<?php echo $this->Form->input('fecha_f', array(
				'label' => false,
		   		));
		   	?>
		</td>
	</tr>
	<tr>
		<td colspan="2"><?php echo $this->Form->submit('Ver Reportes'); ?></td>
	</tr>
</table>
<?php echo $this->Form->end();?>
<table class="dt" id="afluenciaTable">
	<thead>
		<tr>
			<th>Id Usuario</th>
			<th>Parada</th>
			<th>Ruta</th>
			<th>Horario</th>
			<th>Fecha</th>
		</tr>
	</thead>
	<tbody>
		<?php
			if(isset($rrup)){
				foreach ($rrup as $key => $user) {
					echo $this->Html->tableCells(array(array(
							$user['RecorridoRealizadoUsuarioParada']['id_usuario'],
							$user['RecorridoRealizadoUsuarioParada'][0]['nombre_parada'],
							$user['RecorridoRealizadoUsuarioParada'][0]['nombre_ruta'],
							$user['RecorridoRealizadoUsuarioParada'][0]['nombre_horario'],
							$user['RecorridoRealizadoUsuarioParada'][0]['fecha'],
					)));
				}
			}
		?>
	</tbody>
	<tfoot>
		<tr>
			<td><input type="text" value="Buscar"></td>
			<td><input type="text" value="Buscar"></td>
			<td><input type="text" value="Buscar"></td>
			<td><input type="text" value="Buscar"></td>
			<td><input type="text" value="Buscar"></td>
		</tr>
	</tfoot>
</table>
